package dp;

/**
 * LCS 01. 下载插件
 */
public class LCS01 {
    public boolean canJump(int[] nums) {
        int len = nums.length;
        int target = len - 1;
        int[] dp = new int[len];
        dp[0] = 1;
        for (int i = 0; i < len; i++) {
            if (dp[i] != 0) {
                for (int j = 1; j <= nums[i]; j++) {
                    int pos = i + j;
                    if (pos < target) {
                        dp[pos] = 1;
                    } else if (pos == target) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        boolean flag = new LCS01().canJump(new int[]{3,2,1,0,4});
        System.out.println(flag);
    }
}
